package com.huang.datebase;

import com.huang.info.UserInfo;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class UserReg {
	/*
	用户注册
	 */


	public boolean reg(UserInfo userInfo){

		Connection connection = null;
		PreparedStatement ps = null;

		try {
			connection = DbUtil.getConnection();

			String sql = "INSERT INTO user_info (phone,password,sex,hobby,age,header,education,myself) VALUES(?,?,?,?,?,?,?,?)";

			ps = connection.prepareStatement(sql);

			ps.setString(1, userInfo.getPhone());
			ps.setString(2, userInfo.getPassword());
			ps.setString(3, userInfo.getSex());
			ps.setString(4, userInfo.getHobby());
			ps.setString(5, userInfo.getAge()+"");
			ps.setString(6, userInfo.getHeader());
			ps.setString(7, userInfo.getEducation());
			ps.setString(8, userInfo.getMyself());

			int rl = ps.executeUpdate();

			return true;

		} catch (SQLException throwables) {
			throwables.printStackTrace();
			return false;
		}finally {
			DbUtil.close(connection,null,ps,null);
		}

	}
}
